﻿/* ********************************************************************************
 * 名称：City_DomainService
 * 描述：City  领域服务接口实现类（本类通过CodeSmith软件生成生成）
 * 创建人：HFL
 * 创建日期：2020-06-29 17:29:32
 * 修改人：
 * 修改日期：
 * *******************************************************************************/
using WPay.Domain.Base;
using WPay.Domain.Model.DTOs;
using WPay.Domain.Model.Entities;
using WPay.Domain.MainModule.Interface.DomainServices;
using WPay.Domain.MainModule.Interface.RepositoryServices;
using WPay.Infrastructure.EFCore;
using WPay.Infrastructure.Unity;
using WPay.Domain.Model.DTOs.Parms;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Model.DTO.Manager;
using Utility.Enums;
using System.Linq;
using Utility;
using AutoMapper;
using Microsoft.AspNetCore.Http;

namespace WPay.Domain.MainModule
{
    /// <summary>
    /// City 领域服务接口实现类
    /// </summary>
    public class City_DomainService: ICity_DomainService
    {
    
        /// <summary>
        /// City 领域服务接口
        /// </summary>
        private ICity_RepositoryService city_RepositoryService;
        private readonly IEfCore_RepositoryService _efCore_RepositoryService;
        private Entities db;
        
        /// <summary>
        /// 带参构造，用于IOC
        /// </summary>
        public City_DomainService(ICity_RepositoryService _city_RepositoryService
        ,IEfCore_RepositoryService efCore_RepositoryService)
        {
            city_RepositoryService = _city_RepositoryService;
            _efCore_RepositoryService = efCore_RepositoryService;
            db = _efCore_RepositoryService.DbContext();
        }
        
        /*业务扩展代码*/
        #region 业务扩展代码
         /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="model"></param>
        /// <param name="httpRequest"></param>
        /// <returns></returns>
        public  void SaveCity(City model, HttpRequest httpRequest)
        {
           
            //if (string.IsNullOrEmpty(model.ID))//Add
            //{
               // model.ID = System.Guid.NewGuid().ToString();
               //_efCore_RepositoryService.Add(model);
          // }
           // else//Editor
           // {
               // var old = _efCore_RepositoryService.GetByCondition(new DirectSpecification<City>(x => x.ID == model.ID));
                       // old.ID=model.ID;
                       // old.ProvinceId=model.ProvinceId;
                       // old.CityName=model.CityName;
                       // old.CityCode=model.CityCode;
              //  _efCore_RepositoryService.Update(old, 
                  // x =>x.ProvinceId,
                  // x =>x.CityName,
                  // x =>x.CityCode,
              // x => x.ID);
          // }
          //  _efCore_RepositoryService.SaveChanges();
        }
        
        /// <summary>
        /// 删除City
        /// </summary>
        /// <param name="deld"></param>
        /// <returns></returns>
        public IEnumerable<string> DelCity(HttpRequest httpRequest)
        {
           // IEnumerable<string> deld = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(httpRequest.Form["delds"]);
           // _efCore_RepositoryService.LogicDelete(new DirectSpecification<City>(y => deld.Contains(y.ID)));
           // var names = (_efCore_RepositoryService.GetMany(new DirectSpecification<City>(y => deld.Contains(y.ID)))
          //          ).Select(x => x.ID);
            //new UserBLL().AddLog("删除支付账户", $"{string.Join(",", names)}支付账户被删除");
          //  _efCore_RepositoryService.SaveChanges();
           // return names;
           return null;


        }
        #endregion
    }
}
